﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            //EoL1();   
            EoL2();
        }

        private static void EoL2()
        {
            double c = 100;
            Console.WriteLine("1、存款，2、取款");
            int a = int.Parse(Console.ReadLine());
            switch (a)
            {
                case 1:
                    Console.WriteLine("输入金额");
                    double d = double.Parse(Console.ReadLine());
                    c = c + d;
                    Console.WriteLine("总金额为"+c);
                    EoL2();
                    break;
                case 2:
                    Console.WriteLine("输入金额");
                    double b = double.Parse(Console.ReadLine());
                    if (b>c)
                    {
                        throw new ArgumentOutOfRangeException("取款金额大于余额，请重新输入");
                    }
                    else
                    {
                        Console.WriteLine("获得金额"+b);
                    }
                    EoL2();
                    break;
                default:
                    break;
            }
        }

        private static void EoL1()
        {
            float[] a = new float[5];
            int b = 0;
            float sum = 0;
            try
            {
                for (int i = 0; i < a.Length; i++)
                {
                    Console.WriteLine("输入第" + (i + 1) + "考生成绩");
                    a[i] = float.Parse(Console.ReadLine());
                }

            }
            catch (FormatException e)
            {
                Console.WriteLine("异常已处理");
            }
            catch (OverflowException e)
            {
                Console.WriteLine("异常已处理");
            }
            catch (Exception e)
            {
                Console.WriteLine("异常已处理");
            }
            finally
            {
                foreach (var c in a)
                {
                    b = b + 1;
                    sum = sum + c;
                }
                Console.WriteLine("学生总数为" + b);
                Console.WriteLine("学生总成绩为" + sum);
                Console.WriteLine("学生平均分为" + sum / 5);
            }
        }
    }
}
